package com.sjgs.gis.domain;



import com.sjgs.gis.domain.enumeration.ChunkStatus;
import com.sjgs.gis.domain.enumeration.ChunkType;
import lombok.*;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;

import java.io.Serializable;

/**
 * A chunk.
 */
@Table(value = "chunk")
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
//@Document
@Data
public class Chunk implements Serializable {
    private static final long serialVersionUID = 1L;

    //@AutoIncKey
    @Id
    Long id=null;

    @Column
    @NonNull
    String fkey;

    @Column(value = "chunk_count")
    @NonNull
    Long count = 0L;

    @Column
    @NonNull
    Long index = 0L;

    @Column(value = "chunk_start")
    @NonNull
    Long start = 0L;

    @Column(value = "chunk_end")
    @NonNull
    Long end = 0L;

    @Column
    @NonNull
    String hash;

    @Column
    Integer type = ChunkType.CHUNK_SIZE_LOW.ordinal();
    /*
     * 1-完成 0-未完成
     */
    @Column
    Integer status = ChunkStatus.PENDING.ordinal();

    @Column(value = "chunk_addr")
    String chunkAddr = null;

    public Chunk(String fkey, Long count, Long index, String hash, Long start, Long end) {
        this.fkey = fkey;
        this.count = count;
        this.index = index;
        this.hash = hash;
        this.start = start;
        this.end = end;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }

    public Long getIndex() {
        return index;
    }

    public void setIndex(Long index) {
        this.index = index;
    }

    public Long getStart() {
        return start;
    }

    public void setStart(Long start) {
        this.start = start;
    }

    public Long getEnd() {
        return end;
    }

    public void setEnd(Long end) {
        this.end = end;
    }

    public String getFkey() {
        return fkey;
    }

    public void setFkey(String fkey) {
        this.fkey = fkey;
    }

    public String getHash() {
        return hash;
    }

    public void setHash(String hash) {
        this.hash = hash;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getChunkAddr() {
        return chunkAddr;
    }

    public void setChunkAddr(String chunkAddr) {
        this.chunkAddr = chunkAddr;
    }

    public Long getSize() {
        return this.end - this.start;
    }
}
